<?php
$action=$_POST["action"];
if($action == 1)
{
$domain=$_POST["domain"];
$email=$_POST["email"];
$password=$_POST["password"];
$password_1=$_POST["password_1"];
$quota=$_POST["quota"];
//check posts
$errors=0;
if(empty($email)){echo "<h3>E-mail empty</h3>"; $errors++;}
if(empty($password)){echo "<h3>Password empty</h3>"; $errors++;}
if($password != $password_1) {echo "<h3>Password invalid or does not match</h3>"; $errors++;}
$email="$email@$domain";

include_once("user/check_email.php");

if($errors > 0){echo "<h3>Try again!</h3>"; include_once("footer.php"); die();}

$checkUser=mysql_query("SELECT email from users WHERE email='$email'");
$nUser=mysql_num_rows($checkUser);
if($nUser > 0) {echo "<h3>Email <br><i>$email</i> <br>exist!</h3>Try again";  include_once("footer.php"); die();}

//if all is ok - insert user
$insUser=mysql_query("INSERT INTO `users` (`email`, `password`, `quota`) VALUES ('$email', ENCRYPT('$password'), '$quota')") or die (mysql_error());
$affUser=mysql_affected_rows();
if($affUser > 0){ 
//mail('$email,'Welcome','Have fun with your new mail account','postmaster@oraromaniei.com');
include_once("user/send_email.php");
echo "<h3>New user $email</h3><b>created!</b>";
}


?>

<br /><br />
<br /><br />
<?php
}
?>
